package utils;

import java.util.HashSet;
import java.util.Set;

public class CollectionOps {
	public static <T> HashSet<T> intersection(Set<T> a, Set<T> b){
		HashSet<T> result=new HashSet<T>();
		for(T elem : a)
		{
			if(b.contains(elem))
				result.add(elem);
		}
		
		return result;
	}
	public static <T> HashSet<T> union(Set<T> a, Set<T> b){
		HashSet<T> result=new HashSet<T>();
		result.addAll(a);
		result.addAll(b);
		return result;
	}
	public static <T> HashSet<T> minus(Set<T> a, Set<T> b)
	{
		HashSet<T> result=new HashSet<T>(a);
		assert a.size()>b.size();
		
		for(T elem: b)
		{
			result.remove(elem);
		}
		return result;
		
		
	}
	
}
